﻿<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"
    xmlns:Silverlight="clr-namespace:BrasilFramework.Controle.Silverlight" xmlns:Conversores="clr-namespace:BrasilFramework.Controle.Silverlight.Conversores">
    
    <!-- Custom toggle button template -->
    <Style x:Name="ComboToggleButton" TargetType="ToggleButton">
        <Setter Property="Foreground" Value="#FF333333"/>
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Background" Value="#FF1F3B53"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid>
                        <Rectangle Fill="Transparent" />
                        <ContentPresenter
                            x:Name="contentPresenter"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            Margin="{TemplateBinding Padding}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Custom control template used for the IntelliSense sample -->
    <Style TargetType="Silverlight:AutoCompleteComboBox">

        <!-- ComboBox should not perform text completion by default -->
        <Setter Property="IsTextCompletionEnabled" Value="True" />

        <!-- The minimum prefix length should be 0 for combo box scenarios -->
        <Setter Property="MinimumPrefixLength" Value="0" />

        <!-- Regular template values -->
        <Setter Property="FilterMode" Value="Contains"/>
        <Setter Property="Background" Value="#FF1F3B53"/>
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFA3AEB9" Offset="0"/>
                    <GradientStop Color="#FF8399A9" Offset="0.375"/>
                    <GradientStop Color="#FF718597" Offset="0.375"/>
                    <GradientStop Color="#FF617584" Offset="1"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:AutoCompleteBox">
                    <Grid Margin="{TemplateBinding Padding}">
                        <TextBox IsTabStop="True" x:Name="Text" Style="{TemplateBinding TextBoxStyle}" Margin="0" />
                        <ToggleButton 
                                x:Name="DropDownToggle"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center"
                                Style="{StaticResource ComboToggleButton}"
                                Margin="0"
                                HorizontalContentAlignment="Center" 
                                Background="{TemplateBinding Background}" 
                                BorderThickness="0" 
                                Height="16" Width="16">
                            <ToggleButton.Content>
                                <Path x:Name="BtnArrow" Height="4" Width="8" Stretch="Uniform" Data="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z " 
                                          Margin="0,0,6,0" HorizontalAlignment="Right">
                                    <Path.Fill>
                                        <SolidColorBrush x:Name="BtnArrowColor" Color="#FF333333"/>
                                    </Path.Fill>
                                </Path>
                            </ToggleButton.Content>
                        </ToggleButton>
                        <Popup x:Name="Popup">
                            <Border x:Name="PopupBorder" HorizontalAlignment="Stretch" Opacity="1.0" BorderThickness="0" CornerRadius="3">
                                <Border.RenderTransform>
                                    <TranslateTransform X="2" Y="2" />
                                </Border.RenderTransform>
                                <Border.Background>
                                    <SolidColorBrush Color="#11000000" />
                                </Border.Background>
                                <Border HorizontalAlignment="Stretch" BorderThickness="0" CornerRadius="3">
                                    <Border.Background>
                                        <SolidColorBrush Color="#11000000" />
                                    </Border.Background>
                                    <Border.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <SkewTransform />
                                            <RotateTransform />
                                            <TranslateTransform X="-1" Y="-1" />
                                        </TransformGroup>
                                    </Border.RenderTransform>
                                    <Border HorizontalAlignment="Stretch" Opacity="1.0" Padding="2" BorderThickness="2" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="3">
                                        <Border.RenderTransform>
                                            <TransformGroup>
                                                <ScaleTransform />
                                                <SkewTransform />
                                                <RotateTransform />
                                                <TranslateTransform X="-2" Y="-2" />
                                            </TransformGroup>
                                        </Border.RenderTransform>
                                        <Border.Background>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#FFDDDDDD" Offset="0"/>
                                                <GradientStop Color="#AADDDDDD" Offset="1"/>
                                            </LinearGradientBrush>
                                        </Border.Background>
                                        <Silverlight:ListBox x:Name="Selector" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemTemplate="{TemplateBinding ItemTemplate}" />
                                    </Border>
                                </Border>
                            </Border>
                        </Popup>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--Circular Gauge Control-->

    <!-- Type converters-->
    <Conversores:ImageOffsetConverter x:Key="imageOffsetConverter" />
    <Conversores:RadiusToDiameterConverter x:Key="radiusToDiameterConverter"/>
    <Conversores:PointerCenterConverter x:Key="pointerCenterConverter"/>
    <Conversores:RangeIndicatorLightPositionConverter x:Key="rangeIndicatorLightPositionConverter"/>
    <Conversores:SizeConverter x:Key="sizeConverter" />
    <Conversores:BackgroundColorConverter x:Key="backgroundColorConverter" />
    <Conversores:GlassEffectWidthConverter x:Key="glassEffectWidthConverter" />
    <Conversores:ColorToSolidColorBrushConverter x:Key="colorToSolidColorBrushConverter" />


    <Style TargetType="Silverlight:CircularGauge" >
        <Setter Property="ResetPointerOnStartUp" Value="True" />
        <Setter Property="ScaleValuePrecision" Value="5" />
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFA3AFD6" Offset="0.321"/>
                    <GradientStop Color="#FF8399A9" Offset="0.674"/>
                    <GradientStop Color="#FF718597" Offset="0.375"/>
                    <GradientStop Color="#FF617584" Offset="1"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="RangeIndicatorThickness" Value="5"/>
        <Setter Property="GaugeBackgroundColor" Value="Black" />
        <Setter Property="BelowOptimalRangeColor" Value="Green" />
        <Setter Property="OptimalRangeColor" Value="Yellow" />
        <Setter Property="AboveOptimalRangeColor" Value="Red" />
        <Setter Property="DialTextColor" Value="White" />
        <Setter Property="DialTextFontSize" Value="8" />

        <Setter Property="Template" >
            <Setter.Value>
                <ControlTemplate TargetType="Silverlight:CircularGauge">
                    <!-- Root Grid-->
                    <Grid x:Name="LayoutRoot" 
                          Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Radius, Converter={StaticResource radiusToDiameterConverter}}" 
                          Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Radius, Converter={StaticResource radiusToDiameterConverter}}" >


                        <Ellipse x:Name="OuterFrame" StrokeThickness="16" 
                                 Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Radius, Converter={StaticResource radiusToDiameterConverter}}" 
                                 Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Radius, Converter={StaticResource radiusToDiameterConverter}}" 
                                 Fill="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=GaugeBackgroundColor, Converter={StaticResource backgroundColorConverter}}">

                            <Ellipse.Stroke>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF636060" Offset="1"/>
                                    <GradientStop Color="#FF5F5C5C" Offset="0"/>
                                    <GradientStop Color="#FFEEDEDE" Offset="0.35"/>
                                    <GradientStop Color="#FFA09595" Offset="0.705"/>
                                </LinearGradientBrush>
                            </Ellipse.Stroke>
                        </Ellipse>


                        <!-- Gauge Image -->
                        <Image Source="{TemplateBinding ImageSource}" 
                               Width="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=ImageSize, Converter={StaticResource sizeConverter}, ConverterParameter=Width }" 
                               
                               Height="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=ImageSize, Converter={StaticResource sizeConverter}, ConverterParameter=Height }"
                               
                               RenderTransform="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=ImageOffset, Converter={StaticResource imageOffsetConverter}}">

                        </Image>

                        <!-- Dial Text -->
                        <TextBlock Text="{TemplateBinding DialText}"  
                                   HorizontalAlignment="Center" VerticalAlignment="Center"  
                                   Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=DialTextColor, Converter={StaticResource colorToSolidColorBrushConverter}}"
                                   FontSize="{TemplateBinding DialTextFontSize}"                             
                                   FontWeight="Bold"
                                                         
                              RenderTransform="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=DialTextOffset, Converter={StaticResource rangeIndicatorLightPositionConverter}}">

                        </TextBlock>

                        <!-- Pointer -->
                        <Path x:Name="Pointer" Stroke="#FFE91C1C" StrokeThickness="2" 
                              Width="{TemplateBinding PointerLength}" 
                              Height="{TemplateBinding PointerThickness}" HorizontalAlignment="Center"
                              Data="M1,1 L1,10 L156,6 z" Stretch="Fill"  RenderTransformOrigin="0,0.5" 
                              RenderTransform="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=PointerLength, Converter={StaticResource pointerCenterConverter}}">
                            <Path.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF890A0A" Offset="0.197"/>
                                    <GradientStop Color="#FFC40808" Offset="1"/>
                                    <GradientStop Color="#FFE32323" Offset="0.61"/>
                                </LinearGradientBrush>
                            </Path.Fill>

                        </Path>


                        <!--Pointer Cap-->
                        <Ellipse x:Name="PointerCap" Height="{TemplateBinding PointerCapRadius}" Width="{TemplateBinding PointerCapRadius}" StrokeThickness="4" Opacity="1" >
                            <Ellipse.Stroke>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF000000" Offset="0.675"/>
                                    <GradientStop Color="#FFC1B5B5" Offset="0.031"/>
                                </LinearGradientBrush>
                            </Ellipse.Stroke>
                            <Ellipse.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF152029" Offset="0.846"/>
                                    <GradientStop Color="#FF140204" Offset="0.342"/>
                                </LinearGradientBrush>
                            </Ellipse.Fill>
                        </Ellipse>

                        <!--Range indicator light-->
                        <Ellipse x:Name="RangeIndicatorLight" 
                                  Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RangeIndicatorLightRadius, Converter={StaticResource radiusToDiameterConverter}}" 
                                  Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RangeIndicatorLightRadius, Converter={StaticResource radiusToDiameterConverter}}" 
                                
                                RenderTransform="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                                Path=RangeIndicatorLightOffset, Converter={StaticResource rangeIndicatorLightPositionConverter}}">
                            <!--Range indicator light off position effect-->
                            <Ellipse.Fill>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                                    <GradientStop Color="LightGray" Offset="0.2" />
                                    <GradientStop Color="Gray" Offset="0.5" />
                                    <GradientStop Color="Black" Offset="0.8" />
                                </LinearGradientBrush>
                            </Ellipse.Fill>
                        </Ellipse>

                        <!--Glass effect ellipse-->
                        <Path x:Name="GlassEffect" StrokeThickness="1" Stretch="Fill" VerticalAlignment="Bottom"
                              Height="{TemplateBinding Radius}"
                              Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Radius, Converter={StaticResource glassEffectWidthConverter}}" 
                              Opacity="0.18" Data="M265.99997,151.00005 C263.99994,194.00003 209.55908,259 135.00064,259 C60.442207,259 11,200.00003 5.9999995,157.00005 C5.0181994,148.55656 73.000877,112.00006 137.00053,112.00007 C199.00887,112.00008 266.72015,135.5164 265.99997,151.00005 z">
                            <Path.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#68FCFCFC"/>
                                    <GradientStop Color="#FFF8FCF8" Offset="1"/>
                                </LinearGradientBrush>
                            </Path.Fill>
                        </Path>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--Circular Gauge Control-->

</ResourceDictionary>